package com.tenglong.teacher.ui.adapter.viewholder;

import android.view.View;
import android.widget.TextView;

import com.tenglong.teacher.R;
import com.tenglong.teacher.data.resultInfo.RelateHeaderData;
import com.tenglong.teacher.ui.adapter.RelateScourseAdapter;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;


public class RelateCradeOrScourseViewHolder extends BaseViewHolder<RelateHeaderData.ScourseName> {
    private TextView tv;
    private RelateScourseAdapter.RelateScourseListener listener;
    private RelateHeaderData.ScourseName info;

    public RelateCradeOrScourseViewHolder(View itemView) {
        super(itemView);
        initView();
        setListeners();
    }

    public RelateCradeOrScourseViewHolder(View itemView, RelateScourseAdapter.RelateScourseListener listener) {
        this(itemView);
        this.listener = listener;
    }


    private void setListeners() {
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onRelateScourseListener(info, getLayoutPosition());
                }
            }
        });
    }

    private void initView() {
        tv = itemView.findViewById(R.id.tv);
    }

    @Override
    public void setLayoutInfo(RelateHeaderData.ScourseName info) {
        this.info = info;
        tv.setText(info.name == null ? info.label : info.name);
        tv.setSelected(info.isSele);
    }
}
